package com.cyzy.mqlistener;

import com.alibaba.fastjson2.JSON;
import com.cyzy.vo.ExamAdmin;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(topic = "exam-exercise",consumerGroup = "consumer-demo1")
public class ConsumerListener implements RocketMQListener<String> {

    @Override
    public void onMessage(String message){
        //MQ策略：如果消费时，报异常了，这条消息，会重复发给你
        System.out.println("消费者接收到消息：" + message);
        //处理消息
        ExamAdmin examAdmin = JSON.parseObject(message, ExamAdmin.class);
        System.out.println("18---------:"+examAdmin);
    }

}
